<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>二次元の网名生成器 - 创造你的专属动漫风格昵称</title>
    <style>
        :root {
            --anime-pink: #FF69B4;
            --anime-blue: #7EC2FF;
            --bg-color: #FFF6F9;
            --text-primary: #333333;
            --text-secondary: #666666;
        }
        @keyframes falling {
            0% {
                transform: translate(0, -10vh) rotate(0deg);
                opacity: 1;
            }
            100% {
                transform: translate(100px, 100vh) rotate(360deg);
                opacity: 0;
            }
        }

        .sakura {
            position: fixed;
            pointer-events: none;
            z-index: 1000;
        }

        .sakura::before {
            content: '🌸';
            font-size: 20px;
            position: absolute;
            animation: falling 6s linear infinite;
        }

        body {
            font-family: 'Microsoft YaHei', '微软雅黑', sans-serif;
            margin: 0;
            padding: 40px 20px;
            background-color: var(--bg-color);
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" viewBox="0 0 60 60"><path d="M30 5L35 15L45 15L37 22L40 32L30 26L20 32L23 22L15 15L25 15L30 5Z" fill="%23FFB6C1" fill-opacity="0.2"/></svg>');
            color: var(--text-primary);
            overflow-x: hidden;
        }
        .container {
            max-width: 680px;
            margin: 0 auto;
            padding: 40px;
            background-color: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            box-shadow: 0 8px 30px rgba(255,105,180,0.15);
            position: relative;
            overflow: hidden;
        }
        .container::before {
            content: '';
            position: absolute;
            top: -10px;
            right: -10px;
            width: 100px;
            height: 100px;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><path d="M20,20 Q50,10 80,20 T20,20" fill="none" stroke="%23FFB6C1" stroke-width="3"/></svg>');
            opacity: 0.5;
        }
        h1 {
            font-size: 48px;
            font-weight: 700;
            text-align: center;
            margin-bottom: 12px;
            background: linear-gradient(135deg, var(--anime-pink) 0%, var(--anime-blue) 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
            font-family: '华文行楷', 'Microsoft YaHei', cursive;
        }
        .subtitle {
            text-align: center;
            color: var(--text-secondary);
            font-size: 17px;
            margin-bottom: 40px;
            font-family: '楷体', 'KaiTi', serif;
        }
        .input-group {
            margin-bottom: 32px;
            position: relative;
        }
        input[type="text"] {
            width: 100%;
            padding: 16px;
            font-size: 17px;
            border: 2px solid var(--anime-pink);
            border-radius: 12px;
            background-color: white;
            color: var(--text-primary);
            margin-bottom: 16px;
            transition: all 0.3s ease;
            font-family: '微软雅黑', 'Microsoft YaHei', sans-serif;
        }
        input[type="text"]:focus {
            outline: none;
            box-shadow: 0 0 0 3px rgba(255,105,180,0.3);
            transform: scale(1.01);
        }
        button {
            width: 100%;
            padding: 16px;
            background: linear-gradient(135deg, var(--anime-pink) 0%, var(--anime-blue) 100%);
            color: white;
            border: none;
            border-radius: 12px;
            font-size: 18px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            font-family: '微软雅黑', 'Microsoft YaHei', sans-serif;
        }
        button::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
            transition: 0.5s;
        }
        button:hover::before {
            left: 100%;
        }
        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(255,105,180,0.3);
        }
        button:active {
            transform: translateY(0);
        }
        button:disabled {
            background: var(--text-secondary);
            transform: none;
            box-shadow: none;
        }
        .loading {
            text-align: center;
            color: var(--text-secondary);
            font-size: 17px;
            display: none;
            margin: 24px 0;
            font-family: '微软雅黑', 'Microsoft YaHei', sans-serif;
        }
        .error {
            color: var(--anime-pink);
            text-align: center;
            margin: 16px 0;
            display: none;
            font-size: 15px;
            font-family: '微软雅黑', 'Microsoft YaHei', sans-serif;
        }
        .results {
            margin-top: 40px;
            display: flex;
            flex-direction: column;
            gap: 24px;
            justify-content: center;
            align-items: center;
        }
        .name-card {
            background-color: white;
            border: 2px solid var(--anime-pink);
            padding: 24px;
            border-radius: 16px;
            transition: all 0.3s ease;
            position: relative;
            width: 66%;
            margin: 0 auto;
            display: flex;
            flex-direction: column;
        }
        .name-card::after {
            content: '❀';
            position: absolute;
            top: 10px;
            right: 10px;
            color: var(--anime-pink);
            opacity: 0.5;
            font-size: 20px;
        }
        .name-card:hover {
            transform: translateY(-4px) rotate(1deg);
            box-shadow: 0 8px 24px rgba(255,105,180,0.2);
        }
        .chinese-name {
            font-size: 32px;
            color: var(--anime-pink);
            margin-bottom: 16px;
            font-weight: 700;
            text-align: center;
            font-family: '华文行楷', 'Microsoft YaHei', cursive;
        }
        .meaning {
            color: var(--text-secondary);
            line-height: 1.6;
            font-size: 15px;
            font-family: '楷体', 'KaiTi', serif;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>二次元の网名生成器</h1>
        <div class="subtitle">创造你的专属动漫风格昵称 · Create Your Anime-Style Nickname</div>
        <div class="input-group">
            <input type="text" id="englishName" placeholder="输入你喜欢的动漫角色或人物名称" required>
            <button id="generateBtn" onclick="generateNames()">开始生成 · Generate</button>
        </div>
        <div class="loading" id="loading">正在生成你的专属昵称...</div>
        <div class="error" id="error"></div>
        <div class="results" id="results"></div>
    </div>
    <script>
        function createSakura() {
            const sakura = document.createElement('div');
            sakura.className = 'sakura';
            sakura.style.left = Math.random() * window.innerWidth + 'px';
            document.body.appendChild(sakura);

            setTimeout(() => {
                sakura.remove();
            }, 6000);
        }

        function startSakuraAnimation() {
            setInterval(createSakura, 300);
        }

        window.addEventListener('load', startSakuraAnimation);

        async function generateNames() {
            const englishName = document.getElementById('englishName').value.trim();
            if (!englishName) {
                showError('请输入角色或人物名称');
                return;
            }

            const button = document.getElementById('generateBtn');
            const loading = document.getElementById('loading');
            const results = document.getElementById('results');
            const error = document.getElementById('error');

            button.disabled = true;
            loading.style.display = 'block';
            error.style.display = 'none';
            results.innerHTML = '';

            try {
                const prompt = `基于动漫角色/人物"${englishName}"生成3个富有创意和意义的中文网名。每个网名应：
1. 体现角色的个性和背景故事
2. 适当融入中国文化元素和网络流行元素
3. 富有创意且令人印象深刻
4. 适合网络使用且保持文化适当性

请按以下格式回复：
1. [中文网名1]
寓意：[中文含义]
Meaning: [英文含义]

2. [中文网名2]
寓意：[中文含义]
Meaning: [英文含义]

3. [中文网名3]
寓意：[中文含义]
Meaning: [英文含义]`;

                const response = await fetch('https://ark.cn-beijing.volces.com/api/v3/chat/completions', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                        'Authorization': 'Bearer 7917efa3-872c-47d1-8402-d627028e9abe'
                    },
                    body: JSON.stringify({
                        model: 'ep-20250321131047-4dp8c',
                        messages: [
                            {role: 'system', content: '你是一个擅长创造富有创意的中文网名的生成器，善于将动漫元素、文化元素和人物特征融入网名创作中。'},
                            {role: 'user', content: prompt}
                        ]
                    })
                });

                if (!response.ok) {
                    throw new Error('API请求失败');
                }

                const data = await response.json();
                const generatedNames = data.choices[0].message.content;

                const names = generatedNames.split('\n\n').filter(name => name.trim());
                names.forEach(nameBlock => {
                    const card = document.createElement('div');
                    card.className = 'name-card';
                    
                    const lines = nameBlock.split('\n');
                    const chineseName = lines[0].replace(/^\d+\.\s*/, '');
                    const meaning = lines.slice(1).join('\n');
                    
                    card.innerHTML = `
                        <div class="chinese-name">${chineseName}</div>
                        <div class="meaning">${meaning}</div>
                    `;
                    results.appendChild(card);
                });
            } catch (err) {
                showError('发生错误，请稍后重试');
                console.error('Error:', err);
            } finally {
                button.disabled = false;
                loading.style.display = 'none';
            }
        }

        function showError(message) {
            const error = document.getElementById('error');
            error.textContent = message;
            error.style.display = 'block';
        }
    </script>
</body>
</html>